package com.java.ssm.service.impl;

import com.java.ssm.dao.PickingDao;
import com.java.ssm.entity.Picking;
import com.java.ssm.service.PickingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Picking)表服务实现类
 *
 * @author makejava
 * @since 2021-01-21 08:42:16
 */
@Service("pickingService")
public class PickingServiceImpl implements PickingService {
    @Resource
    private PickingDao pickingDao;

    /**
     * 通过ID查询单条数据
     *
     * @param pId 主键
     * @return 实例对象
     */
    @Override
    public Picking queryById(Integer pId) {
        return this.pickingDao.queryById(pId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Picking> queryAllByLimit(int offset, int limit) {
        return this.pickingDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param picking 实例对象
     * @return 实例对象
     */
    @Override
    public Picking insert(Picking picking) {
        this.pickingDao.insert(picking);
        return picking;
    }

    /**
     * 修改数据
     *
     * @param picking 实例对象
     * @return 实例对象
     */
    @Override
    public Picking update(Picking picking) {
        this.pickingDao.update(picking);
        return this.queryById(picking.getPId());
    }

    /**
     * 通过主键删除数据
     *
     * @param pId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer pId) {
        return this.pickingDao.deleteById(pId) > 0;
    }
}